package com.cus.tom.transfer.frag;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.cus.tom.transfer.adapter.RecordAdapter;
import com.cus.tom.transfer.databinding.FragRecordBinding;
import com.cus.tom.transfer.view.CustomTabProvider;

public class RecordFragment extends BaseFragment {

    FragRecordBinding binding;
    int type = 0;//0：收； 1：发

    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        binding = FragRecordBinding.inflate(inflater, container, false);
        binding.tab.setCustomTabView(new CustomTabProvider(getActivity()));
        binding.pager.setAdapter(new RecordAdapter(getChildFragmentManager(), type));
        binding.tab.setViewPager(binding.pager);

        binding.type.setOnClickListener(v -> {
            if (type == 0) {
                type = 1;
                binding.type.setText("发");
            } else {
                type = 0;
                binding.type.setText("收");
            }
            binding.pager.setAdapter(new RecordAdapter(getChildFragmentManager(), type));
            binding.tab.setViewPager(binding.pager);
        });

        return binding.getRoot();
    }

    @Override
    protected boolean paddingTop() {
        return true;
    }
}
